﻿/**
 * 显示 toast
 * @param {} page 
 * @param {} message 
 * @param {} hideDelay 
 * @returns {} 
 */
function show(page, message, hideDelay) {
    page.setData({
        toastData: { toast_hidden: "show", toast_message: message }
    });
    if (hideDelay == undefined) {
        hideDelay = 1500;
    }
    if (hideDelay == 0) {
        return;
    }
    if (hideDelay > 0) {
        setTimeout(function () {
            page.setData({
                toastData: { toast_hidden: "hide", toast_message: message }
            });
        }, hideDelay);
    }
}

/**
 * 隐藏 toast
 * @param {} page 
 * @returns {} 
 */
function hide(page) {
    page.setData({
        toastData: { toast_hidden: "hide", toast_message: "" }
    });
}

module.exports = {
    show: show
}